package util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
    public static final SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm");

    public static String format(Date date) {
        return SDF.format(date);
    }

    public static Date parse(String str) throws ParseException {
        return SDF.parse(str);
    }

    // 检查是否为同一天
    public static boolean isSameDay(Date d1, Date d2) {
        return format(d1).split(" ")[0].equals(format(d2).split(" ")[0]);
    }
}